@extends("admin.frame_layout")
<?php
$top_selected = "会员管理";
if ($flag == 1) {
    $page_menu = "全部会员列表";
} elseif ($flag == 2) {
    $page_menu = "未激活会员";
} elseif ($flag == 3) {
    $page_menu = "已冻结会员";
} elseif ($flag == 4) {
    $page_menu = "已禁用会员";
} elseif ($flag == 5) {
    $page_menu = "内部会员列表";
} elseif ($flag == 6) {
    $page_menu = "全部的报单中心";
} elseif ($flag == 7) {
    $page_menu = "申请中的处理";
}
?>
@section('content')
    <div class="rightinfo">
        <div class="tools">
            <form method="get" id="sform" action="{{route('admin.users',['flag' => $flag])}}">
                <ul class="toolbar">
                    <li>
                        <select name="time_type">
                            <option value="1" selected>注册时间</option>
                            <option value="2">激活时间</option>
                        </select>
                    </li>
                    <li>
                        <input type="text" name="start" placeholder="开始时间"
                               onClick="laydate({istime: true,format: 'YYYY-MM-DD hh:mm:ss'})">
                    </li>
                    <li>
                        <input type="text" name="end" placeholder="结束时间"
                               onClick="laydate({istime: true,format: 'YYYY-MM-DD hh:mm:ss'})">
                    </li>
                    <li>
                        <select name="search_type">
                            <option value="1" selected>按会员用户名</option>
                            <option value="7">按会员编号</option>
                            <option value="2">按会员ID</option>
                            {{--<option value="3">按真实姓名</option>--}}
                            {{--<option value="4">按会员手机号</option>--}}
                            <option value="5">按报单中心账号</option>
                            <option value="6">按报单中心ID</option>

                        </select>
                    </li>
                    <li>
                        <input id="search_str" name="search_str" type="text" placeholder="搜索条件">
                    </li>
                    <li>
                        <select name="sort_type">
                            <option value="1" selected> [ 注册时间 ] 降序 ↓</option>
                            <option value="2"> [ 注册时间 ] 升序 ↑</option>
                            <option value="3"> [ 激活时间 ] 降序 ↓</option>
                            <option value="4"> [ 激活时间 ] 升序 ↑</option>
                        </select>
                    </li>
                    <li>
                        <a href="javascript:void(0)" onclick="$('#sform').submit()">
                         <span>
                            <img src="{{asset('admin/imgs/ico06.png')}}" width="20px" height="20px"/>
                         </span>搜索
                        </a>
                    </li>
                </ul>
            </form>
        </div>

        <table class="tablelist">
            <thead>
            <tr>
                <th width="70px">操作</th>
                <th>ID<i class="sort"><img src="{{asset('admin/imgs/px.gif')}}"/></i></th>
                <th>编号<i class="sort"><img src="{{asset('admin/imgs/px.gif')}}"/></i></th>
                <th>用户名</th>
                <th>个人中心</th>
                <th>会员等级</th>
                <th>报单中心</th>
                <th>节点人</th>
                <th>推荐人</th>
                <th>奖金币/冻结</th>
                <th>报单币/冻结</th>
                <th>购物币/冻结</th>
                <th>状态</th>
                <th>激活</th>
                <th>注册时间</th>
                <th>激活时间</th>
            </tr>
            </thead>
            <tbody>

            @foreach($users as $user)
                <tr>
                    <td class="act" bind="#{{$user->id}}">
                        <img src="{{asset('admin/imgs/t05.png')}}"/>菜单
                        <ul id="{{$user->id}}">
                            <li>
                                <a href="{{route('admin.users.edit',['id'=>$user->id])}}">
                                    <img src="{{asset('admin/imgs/d02.png')}}"/> 编辑用户
                                </a>
                            </li>
                            @if($user->ok_status == 0)
                                <li onclick="openOkDlg('{{route('admin.active.user',['id'=>$user->id])}}')">
                                    <img src="{{asset('admin/imgs/d02.png')}}"/> 激活用户
                                </li>
                            @endif
                            <li onclick="openOkDlg('{{route('admin.user.freeze',['id'=>$user->id , 'status'=>$user->status])}}')">
                                <img src="{{asset('admin/imgs/d02.png')}}"/>
                                @if($user->status == \App\Models\MUser::$STATUS_NORMAL ||
                                 $user->status == \App\Models\MUser::$STATUS_STOP)
                                    冻结用户
                                @elseif($user->status == \App\Models\MUser::$STATUS_FREEZE ||
                                $user->status == \App\Models\MUser::$STATUS_STOP_FREEZE)
                                    取消冻结用户
                                @endif
                            </li>
                            <li onclick="openOkDlg('{{route('admin.user.stop',['id'=>$user->id , 'status'=>$user->status])}}')">
                                <img src="{{asset('admin/imgs/d02.png')}}"/>
                                @if($user->status == \App\Models\MUser::$STATUS_NORMAL ||
                                 $user->status == \App\Models\MUser::$STATUS_FREEZE)
                                    禁用用户
                                @elseif($user->status == \App\Models\MUser::$STATUS_STOP ||
                                 $user->status == \App\Models\MUser::$STATUS_STOP_FREEZE)
                                    取消禁用用户
                                @endif
                            </li>
                            <li onclick="openOkDlg('{{route('admin.active.bdzx',['id'=>$user->id])}}')">
                                <img src="{{asset('admin/imgs/d02.png')}}"/>
                                @if($user->bdzx_status == \App\Models\MUser::$BDZX_NO || $user->bdzx_status == \App\Models\MUser::$BDZX_APPLY)
                                    开通报单中心
                                @elseif($user->bdzx_status == \App\Models\MUser::$BDZX_YES)
                                    取消报单中心
                                @endif
                            </li>
                            @if($user->ok_status == 0){{-- 未激活会员可以删除 --}}
                            <li onclick="openOkDlg('{{route('admin.user.del',['id'=>$user->id])}}')">
                                <img src="{{asset('admin/imgs/d02.png')}}"/> 删除
                            </li>
                            @endif
                        </ul>
                    </td>
                    <td>{{$user->id}}</td>
                    <td>{{$user->no}}</td>
                    <td>{{$user->username}}</td>
                    <td><a href="{{route('admin.go',['id'=>$user->id])}}" target="_blank">进入前台</a></td>
                    <td>{{\App\VModels\VVip::vipBySlug($user->vip_slug)->name}}</td>
                    <td>{{$user->bdzxUser->username or "无" }}</td>
                    <td>{{$user->nuser->username or "无" }}</td>
                    <td>{{$user->puser->username or "无" }}</td>
                    <td><span class="green">{{$user->wallet->w1}}</span>&nbsp;/&nbsp;<span
                                class="red">{{$user->wallet->w1_freeze}}</span></td>
                    <td><span class="green">{{$user->wallet->w2}}</span>&nbsp;/&nbsp;<span
                                class="red">{{$user->wallet->w2_freeze}}</span></td>
                    <td><span class="green">{{$user->wallet->w3}}</span>&nbsp;/&nbsp;<span
                                class="red">{{$user->wallet->w3_freeze}}</span></td>
                    <td>
                        {{uStatusStr($user->status)}}
                    </td>
                    <td>
                        @if($user->ok_status == 0)
                            未激活
                        @elseif($user->ok_status == 1)
                            已激活
                        @endif
                    </td>
                    <td>{{date("Y-m-d H:i:s",$user->reg_time)}}</td>
                    <td>{{$user->ok_time != null ? date("Y-m-d H:i:s",$user->ok_time) : '无'}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    @include('admin.coms.fenye')
    @include('admin.coms.dialog')
@endsection
@section('footer')
    <script src="{{asset('admin/js/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            laydate.skin("dahong"); //大红色日期选择皮肤
            //初始化表格操作菜单
            $('.tablelist tbody tr:odd').addClass('odd');
            $(".tablelist .act").hover(function () {
                $($(this).attr("bind")).show();
            }, function () {
                $($(this).attr("bind")).hide();
            });
        });
    </script>
@endsection

